﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuimini/css/public.css" rel="stylesheet" />


</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <fieldset class="table-search-fieldset">
                <legend>一车间前道流程卡</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form layui-form-pane" action="">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">关键字</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="name" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">状态</label>
                                <div class="layui-input-inline">
                                    <select name="State" lay-search id="State">
                                        <option value="1" selected="selected">未完成</option>
                                        <option value="2">已完成</option>
                                        <option value="0">全部</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>
            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                    {{#  if( @(Web.Common.Common.IsAuthoritys(12)) == 1){ }}
                    <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                    @*<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>*@
                    {{#  } }}
                </div>
            </script>
            <table class="layui-hide" id="table" lay-filter="currentTableFilter"></table>
            <script type="text/html" id="currentTableBar">
                <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="details">添加工序</a>
                {{#  if( @(Web.Common.Common.IsAuthoritys(12)) == 1){ }}
                <a class="layui-btn layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
                <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
                {{#  if(d.State==0){ }}
                <a class="layui-btn layui-btn-xs layui-bg-cyan" lay-event="touchan">投产</a>
                {{#  } }}
                {{#  if(d.State==1){ }}
                <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="jiaofu">交付</a>
                <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="wancheng">完成</a>
                {{#  } }}
                {{#  } }}
                    <a class="layui-btn layui-btn-xs layui-btn-normal" href="/Bill1/Down?ID={{ d.ID }}">下载</a>

</script>
        </div>
    </div>


    <script src="~/layui/layui.js"></script>
    <script src="~/layuimini/js/lay-config.js"></script>
    <script src="~/scripts/Print.js"></script>
    <script>
        layui.use(['form', 'table', 'miniTab'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                miniTab = layui.miniTab;

        table.render({
            elem: '#table',
            method: 'post',
            url: '@Url.Action("IndexListAsync", "Bill1")',
            request: {
                pageName: 'PageIndex' //页码的参数名称，默认：page
               , limitName: 'PageSize' //每页数据量的参数名，默认：limit
            },
            where: {
                Search: $('#name').val(),
                State: $('#State').val()
            },
            cellMinWidth:120,
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print'],
            cols: [[
                { type: "checkbox", width: 50 },
                { type: 'numbers', title: '序号', width: 50 },
                { field: 'ID', title: 'ID', width: 100, hide: true },
                { field: 'Code', title: '卡号' },
                { field: 'JinDu', title: '进度' },
                { field: 'BigClassName', title: '大类' },
                { field: 'GoodsModel', title: '产品型号' },
                //{ field: 'GoodsCode', title: '产品编码' },
                { field: 'SourceGoodsModel', title: '硅片型号' },
                { field: 'XinPianMianJi', title: '芯片面积' },
                { field: 'DianZhu', title: '电阻率' },
                { field: 'LingMan', title: '领料人' },
                { field: 'LingDate', title: '领料日期' },
                { field: 'TouMan', title: '投片负责人' },
                { field: 'TouDate', title: '投片日期' },
                { field: 'Number', title: '产品序号' },
                { field: 'TouQty', title: '投片数量' },
                { field: 'JiaoQty', title: '交付数量' },
                { field: 'HuoYuanHao', title: '货源号' },
                { field: 'JianYanHao', title: '检验号' },
                { field: 'ZhengBei', title: '正背面金属' },
                { field: 'DengJi', title: '质量等级' },
                { field: 'WaiXing', title: '封装外型' },
                { field: 'StateName', title: '状态' },
                { fixed: 'right', title: '操作', toolbar: '#currentTableBar', width: 350 }
            ]],
            limits: [10, 20, 30, 50, 100, 100000000],
            limit: 20,
            page: true,
            //skin: 'line',
            //totalRow: true,
            height: 'full-170',
            size:'sm',
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            RefreshTable();
            return false
        });

        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                var index = layer.open({
                    title: '添加流程卡',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: false,
                    area: ['1050px', '650px'],
                    content: '@Url.Action("IndexEdit", "Bill1")',
                    end: function () {
                        RefreshTable();

                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'delete') {  // 监听删除操作
                var checkStatus = table.checkStatus('table')
                    , data = checkStatus.data;
                if (data.length == 0) {
                    layer.msg('请选择您要删除的数据！', { icon: 5, time: 2000 });
                    return;
                }

                var arr = [];
                for (var i = 0; i < data.length; i++) {
                    arr.push(data[i].ID);
                }

                var ids = arr.join(",");


                layer.confirm('您确定要删除所选数据吗', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("IndexDelAsync", "Bill1")',
                        type: "post",
                        dataType: "json",
                        data: { IDs: ids },
                        success: function (data) {
                            //Info,Success,Warning,Error
                            var type = data.Type;
                            if (type == 1) {
                                layer.msg(data.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(data.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            }
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {

                var index = layer.open({
                    title: '修改流程卡',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: false,
                    area: ['1050px', '650px'],
                    content: '@Url.Action("IndexEdit", "Bill1")' + '?ID=' + data.ID,
                    end: function () {
                        RefreshTable();
                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if (obj.event === 'delete') {
                layer.confirm('您确定要删除所选数据吗', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("ModifyIndexStateAsync", "Bill1")',
                        type: "post",
                        dataType: "json",
                        data: { ID: data.ID ,State:3},
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } else if (obj.event === 'details') {
                miniTab.openNewTabByIframe({
                    href: '@Url.Action("DetailsList", "Bill1")' + '?ID=' + data.ID,
                    title: "流程卡详情",
                });
                return false;
            } else if (obj.event === 'jiaofu') {
                miniTab.openNewTabByIframe({
                    href: '@Url.Action("JiaoFuList", "Bill1")' + '?ID=' + data.ID,
                    title: "流程卡交付详情",
                });
                return false;
            } else if (obj.event === 'touchan') {
                layer.confirm('投产后不能修改流卡信息，是否继续？', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("ModifyIndexStateAsync", "Bill1")',
                        type: "post",
                        dataType: "json",
                        data: { ID: data.ID,State:1 },
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } else if (obj.event === 'wancheng') {
                layer.confirm('确认此流程卡工序全部完成？', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("ModifyIndexStateAsync", "Bill1")',
                        type: "post",
                        dataType: "json",
                        data: { ID: data.ID, State: 2 },
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } else if (obj.event === 'print') {

                    @*$.ajax({
                        url: '@Url.Action("ModifyIndexStateAsync", "Bill1")',
                        type: "post",
                        dataType: "json",
                        data: { ID: data.ID, State: 2 },
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });*@
            //    let html = '<table border="1" cellpadding="0" cellspacing="0" height="100%" width="100%" style="table-layout: fixed; word-break: keep-all;">';
            //    html += '<tr style="height:4%;">';
            //    html += '<th colspan="14">一车间前道工序流程卡</th>';
            //    html += '</tr>';
            //    html += '<tr style="height:6%">';
            //    html += '<td align="center">型号</td>';
            //    html += '<td align="center"></td>';
            //    html += ' <td align="center">编码</td>';
            //    html += '<td align="center"></td>';
            //    html += '<td align="center">卡号</td>';
            //    html += '<td align="center"></td>';
            //    html += ' <td align="center">硅片型号</td>';
            //    html += ' <td align="center"></td>';
            //    html += ' <td align="center">硅片编号</td>';
            //    html += ' <td align="center"></td>';
            //    html += ' <td align="center">电阻率</td>';
            //    html += ' <td align="center"></td>';
            //    html += ' <td align="center">货源号</td>';
            //    html += ' <td align="center"></td>';
            //    html += '</tr>';
            //    html += ' <tr style="height:6%">';
            //    html += ' <td align="center">领料日期</td>';
            //    html += ' <td align="center"></td>';
            //    html += ' <td align="center">领料人</td>';
            //    html += ' <td align="center"></td>';
            //    html += ' <td align="center">投片日期</td>';
            //    html += '<td align="center"></td>';
            //    html += '<td align="center">投片负责人</td>';
            //    html += '<td align="center"></td>';
            //    html += '<td align="center">产品序号</td>';
            //    html += '<td align="center"></td>';
            //    html += '<td align="center">投片数量</td>';
            //    html += '<td align="center"></td>';
            //    html += ' <td align="center">检验号</td>';
            //    html += '<td align="center"></td>';
            //    html += '</tr>';
            //    html += '<tr style="height:6%">';
            //    html += '<td align="center">工序</td>';
            //    html += '<td align="center">接收数</td>';
            //    html += '<td align="center">下传数</td>';
            //    html += ' <td align="center">废品数</td>';
            //    html += '<td align="center">废片原因</td>';
            //    html += '<td align="center">工时(小时)</td>';
            //    html += '<td align="center">工艺条件</td>';
            //    html += '<td align="center">操作者</td>';
            //    html += '<td align="center">生产日期</td>';
            //    html += '<td align="center">检查员</td>';
            //    html += '<td align="center">温度</td>';
            //    html += '<td align="center">湿度</td>';
            //    html += '<td align="center" colspan="2">备注</td>';
            //    html += '</tr>';
            //    for (let i = 0; i < 25; i++) {
            //        html += '<tr style="height:3%;">';
            //        html += ' <td align="center"></td>';
            //        html += ' <td align="center"></td>';
            //        html += '  <td align="center"></td>';
            //        html += '  <td align="center"></td>';
            //        html += '  <td align="center"></td>';
            //        html += '  <td align="center"></td>';
            //        html += ' <td align="center"></td>';
            //        html += '  <td align="center"></td>';
            //        html += '  <td align="center"></td>';
            //        html += '  <td align="center"></td>';
            //        html += '  <td align="center"></td>';
            //        html += ' <td align="center"></td>';
            //        html += ' <td align="center" colspan="2"></td>';
            //        html += '</tr>';
            //    }
            //    html += ' </table>';
            //    $(html).appendTo('#Page01');
            //    Print('#Page01');
                //    $('#Page01').empty();
                //Print('#Page01');
            }
        });
        function RefreshTable() {
            table.reload('table', {
                where: {
                    Search: $('#name').val(),
                    State: $('#State').val()

                }
            }, 'data');

        }

    });
    </script>
</body>
</html>